package com.bw.wxy.common;

import android.content.SharedPreferences;

public class SpUtils {
    private static String name="netcatch";

    public static void saveData(String key,String value){
        SharedPreferences sp = App.getInstance().getApplicationContext().getSharedPreferences(name, 0);
        sp.edit().putString(key,value).commit();
    }

    public static String readData(String key){
        SharedPreferences sp = App.getInstance().getApplicationContext().getSharedPreferences(name, 0);
        return sp.getString(key,"");
    }

    public static boolean getLogin(){
        SharedPreferences sp=App.getInstance().getApplicationContext().getSharedPreferences("login",0);
        boolean aBoolean = sp.getBoolean("isLogin", false);
        return aBoolean;
    }

    public static void editLogin(){
        SharedPreferences sp = App.getInstance().getApplicationContext().getSharedPreferences("login", 0);
        SharedPreferences.Editor edit = sp.edit();
        edit.putBoolean("isLogin",true).commit();
    }

    public static void editFalseLogin(){
        SharedPreferences sp = App.getInstance().getApplicationContext().getSharedPreferences("login", 0);
        SharedPreferences.Editor edit = sp.edit();
        edit.putBoolean("isLogin",false).commit();
    }

    public static String getImg(){
        SharedPreferences sp = App.getInstance().getApplicationContext().getSharedPreferences("headimg", 0);
        String img = sp.getString("img", null);
        return img;
    }

    public static void saveImg(String value){
        SharedPreferences sp = App.getInstance().getApplicationContext().getSharedPreferences("headimg", 0);
        SharedPreferences.Editor edit = sp.edit();
        edit.putString("img",value);
        edit.commit();
    }

}

